class Solution {
public:
    int removeDuplicates(vector<int>& nums) {
        int pos1 = 0;
        int pos2 = 1;
        int sz = nums.size();
        while (pos2 != sz)
        {
            if (nums[pos1] == nums[pos2])
            {
                ++pos2;
            }
            else
            {
                ++pos1;
                nums[pos1] = nums[pos2];
                ++pos2;
            }
        }
        return pos1 + 1;
    }
};